import {
    getAllAlbumApi,
    getAllFrameApi,
    getAllstore
  } from "@/api/order/index";
import {
  getAllOrderRoleApi,
  getAllKzRoleApi,
  getAllDepartmentsApi
} from '@/api/account/index.js'
import store from "@/store";
export const getAlbum = () => {
  getAllAlbumApi().then(res => {
    console.log('获取所有的相册产品', res);
    if (res.rstpCode === '0000') {
      sessionStorage.setItem('bcAlbumList', JSON.stringify(res.data))
      store.dispatch("layout/app/bcAlbumList", res.data);
    } else {
      this.$Message.error(res.rstpMsg);
    }
  })
}

export const getFrame = () => {
  getAllFrameApi().then(res => {
    console.log('获取所有的相框产品', res);
    if (res.rstpCode === '0000') {
      sessionStorage.setItem('bcFrameList', JSON.stringify(res.data))
      store.dispatch("layout/app/bcFrameList", res.data);
    } else {
      this.$Message.error(res.rstpMsg);
    }
  })
}
// 获取所有客资角色
export const getAllkzRole = () => {
  getAllKzRoleApi().then(res => {
    console.log('获取所有客资角色', res);
    if (res.rstpCode === '0000') {
      sessionStorage.setItem('bcKzRoleList', JSON.stringify(res.data))
      store.dispatch("layout/app/bcKzRoleList", res.data);
    } else {
      this.$Message.error(res.rstpMsg);
    }
  })
}
// 获取所有订单角色
export const getAllOrderRole = () => {
  getAllOrderRoleApi().then(res => {
    console.log('获取所有订单角色', res);
    if (res.rstpCode === '0000') {
      sessionStorage.setItem('bcOrderRoleList', JSON.stringify(res.data))
      store.dispatch("layout/app/bcOrderRoleList", res.data);
    } else {
      this.$Message.error(res.rstpMsg);
    }
  })
}
// 获取所有店铺列表
export const getAllstoreList = () => {
  getAllstore().then(res => {
    console.log('获取所有店铺列表', res);
    if (res.rstpCode === '0000') {
      sessionStorage.setItem('bcStoreList', JSON.stringify(res.data))
      store.dispatch("layout/app/bcStoreList", res.data);
    } else {
      this.$Message.error(res.rstpMsg);
    }
  })
}
// 获取所有部门
export const getAllDepartmentsList = () => {
  getAllDepartmentsApi().then(res => {
    console.log('获取所有部门列表', res);
    if (res.rstpCode === '0000') {
      sessionStorage.setItem('bcDepartmentsList', JSON.stringify(res.data))
      store.dispatch("layout/app/bcDepartmentsList", res.data);
    } else {
      this.$Message.error(res.rstpMsg);
    }
  })
}
